﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SDZJ.ExtendControls
{
    public sealed class ExtendLinkButton : System.Web.UI.WebControls.LinkButton
    {
        private string imageUrl = "";
        public string ImageUrl
        {
            get
            {
                return imageUrl;
            }
            set
            {
                imageUrl = value;
            }
        }

        private string imgCss = "";
        public string ImgCss
        {
            get
            {
                return imgCss;
            }
            set
            {
                imgCss = value;
            }
        }

        private string txtCss = "";
        public string TxtCss
        {
            get
            {
                return txtCss;
            }
            set
            {
                txtCss = value;
            }
        }


        public ExtendLinkButton()
            : base()
        {
            //string stylevalue="color:Black;font-size:14px;text-decoration:none;cursor:hand;display:inline-block;padding-left:5px;padding-right:5px;height:18px;";
            this.Style.Add("cursor", "hand");
            this.Style.Add("display", "inline-block");
            //this.Style.Add("color", "Black");
            //this.Style.Add("font-size", "12px");
            //this.Style.Add("text-decoration", "none");

            //this.Style.Add("padding-left", "5px");
            //this.Style.Add("padding-right", "5px");
            //this.Style.Add("height", "20px");            

        }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(this.Text))
            {
                this.Text = this.ID;
            }

            if (!string.IsNullOrEmpty(this.imageUrl))
            {
                string newText = "<img width=5 height=5 src=\"" + this.imageUrl + "\" border=\"0\" style=\"width:16px;height:16px;position:relative;\" class=\"" + imgCss + "\" />";
                newText += "<span style=\"position:relative;\" class=\"" + txtCss + "\">" + this.Text + "</span>";
                this.Text = newText;
            }
            else
            {
                //this.Text = "<span style=\"position:relative;\" class=\"" + txtCss + "\">" + this.Text + "</span>";
                this.Text = "<span class=\"" + txtCss + "\">" + this.Text + "</span>";
            }

            base.Render(writer);
        }
    }
}